$def with (ogtxml, knowinfo, kinfo, resinfo)
$ nofiles = ['PlainText', 'FormalizedText', 'FormattedText', 'Demonstration']
$ allfiles = ['Image', 'Audio', 'Video']

<div role="article" class="coursera-body">
	<div class="container">
		<div class="coursera-full-canvas">
			<div class="row-fluid">
				<div style="margin-bottom: 16px;" class="coursera-edit-page">
					<div class="coursera-edit-page-button"></div>
				</div>				
			</div>
			<div class="coursera-course-content">
				<div style="margin-bottom: 30px;" class="row-fluid">
					<h2>$knowinfo.knowledge : $knowinfo.name</h2>
					<div class="span6">
						<p><b>Name</b>: $kinfo.Name</p>
						$for i,j in kinfo.items():
							$if i not in ['id', 'knowid', 'Name', 'date', 'creator']:
								<p><b>$i</b>: $:j</p>
					</div>
					<div class="span6">
						<div style="position: relative;"></div>
					</div>
				</div>
				$if [m for m in nofiles if m in resinfo.keys()] != []:
					<hr class="coursera-full-page-divider-no_padding">
				$for k in nofiles:
					$if k in resinfo.keys():
						<div class="row-fluid"><h2>$k</h2>
						$for i in resinfo.get(k):
							<div class="span7"><div>
							<h3>Keyword:<a>$i.Keyword</a></h3>
							<p>&nbsp;&nbsp;written by <a href="/users?i=$i.creator">$i.creator</a> at $i.date</p>
							<div class="coursera-course-detail">
								$if k == "Demonstration":
									$if i.FormatOfDemonstration == "JSXGraphJavaScript":
										<div id='demobox' class='jxgbox' style='width:500px; height:500px;'></div>
										<script type='text/javascript'>
											$:i.resource
										</script>
									$elif i.FormatOfDemonstration == "JessieScript":
										<input type="hidden" class="codejxgbox" value="$i.resource" id="jxgbox_demo"/>
										<div id="pro_jxgbox_demo" style="width: 450px; height: 450px; border-style:groove"></div>
									$elif i.FormatOfDemonstration == "GeoGebra":
										<applet name="ggbApplet" code="geogebra.GeoGebraApplet" codebase="http://jars.geogebra.org/webstart/4.2/unsigned/" archive="geogebra.jar" height="400" width="500"> <param name="cache_version" value="geogebra.jar,geogebra_main.jar,geogebra_gui.jar,geogebra_cas.jar,geogebra_algos.jar,geogebra_export.jar,geogebra_javascript.jar,jlatexmath.jar,jlm_greek.jar,jlm_cyrillic.jar,geogebra_properties.jar"/> <param name="cache_version" value="4.0.41.0,4.0.41.0,4.0.41.0,4.0.41.0,4.0.41.0,4.0.41.0,4.0.41.0,4.0.41.0,4.0.41.0,4.0.41.0,4.0.41.0"/> <param name="ggbBase64" value="$i.resource"/> <param name="enableRightClick" value="true"/> <param name="enableLabelDrags" value="false"/> <param name="enableShiftDragZoom" value="true"/> <param name="errorDialogsActive" value="true"/> <param name="showMenuBar" value="false"/> <param name="showToolBar" value="false"/> <param name="showToolBarHelp" value="true"/> <param name="showAlgebraInput" value="false"/> <param name="showResetIcon" value="true"/> <param name="java_arguments" value="-Xmx1024m"/> <param name="useBrowserForJS" value="false"/> <param name="framePossible" value="false"/> <param name="image" value="http://www.geogebra.org/webstart/loading.gif"/> <param name="boxborder" value="false"/> <param name="centerimage" value="true"/>This is a Java Applet created using GeoGebra from www.geogebra.org - it looks like you don't have Java installed, please go to www.java.com</applet>	
								$else:
									$:i.resource
							</div>
							</div>
							</div>
							<div class="span1"></div>
							<div class="span4">
							<div class="coursera-course2-data">
								<h3 class="coursera-course-heading">Your review of this resource</h3>
								<div class="controls">
									<textarea name="" id="$(k)_$(i.id)-text-comments" style="width: 350px; height: 150px" class="large"></textarea>
								</div>
								<div class="shop-rating">
									<span class="title">Click to rate: </span>
									<ul class="rating-level" id="$(k)_$(i.id)">
										<li><a class="one-star" star:value="1" href="#" title="Terrible">1</a></li>
										<li><a class="two-stars" star:value="2" href="#" title="Poor">2</a></li>
										<li><a class="three-stars" star:value="3" href="#" title="Average">3</a></li>
										<li><a class="four-stars" star:value="4" href="#" title="Very Good">4</a></li>
										<li><a class="five-stars" star:value="5" href="#" title="Excellent">5</a></li>
									</ul>
									<span class="result" id="$(k)_$(i.id)-tips"></span> 
									<input type="hidden" id="$(k)_$(i.id)-input" name="" value="3" size="2" />
								</div>
								<input type="button" value="submit" class="btn btn-primary knowledge-rating-level" know_id="$(k)_$(i.id)"/>
							</div>
							</div>
						</div>
				$if [m for m in allfiles if m in resinfo.keys()] != []:
					<hr class="coursera-full-page-divider-no_padding">
				$for k in allfiles:
					$if k in resinfo.keys():
						<div class="row-fluid"><h2>$k</h2>
						$for i in resinfo.get(k):
							<div class="span7">
								<div>
									<h3>Keyword:<a>$i.Keyword</a></h3>
									<p>uploaded by <a href="/users?i=$i.creator">$i.creator</a> at $i.date</p>
									<div class="coursera-course-detail">
										$if k == "Image":
											<img src="$i.localPath" width="300" height="300">
										$elif k == "Audio":
											<embed src="$i.localPath" autoplay="false" autostart="false" controls="console" align="texttop" width="300" height="60" alt="Your browser does not support the audio tag">
											</embed>
											<p>
												<strong>Download audio:</strong> <a href="$i.localPath">Mp3 format | Ogg format | Wav format</a>
											</p>
										$elif k == "Video":
											$if i.VideoFormat == "FLV":
												<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"
													width="500" height="400">
													<param name="movie" value="$i.localPath" />
													<param name="salign" value="lt" />
													<param name="quality" value="high" />
													<param name="flashvars" value="" />
													<embed src="$i.localPath" quality="high" flashvars=""
														scale="noscale" width="500" height="400" salign="LT" type="application/x-shockwave-flash"
														pluginspage="http://www.macromedia.com/go/getflashplayer" />
												</object>
												<p>
													<strong>Download video:</strong> <a href="$i.localPath">FLV format</a>
												</p>
											$elif i.VideoFormat == "AVI" or i.VideoFormat == "DivX":
												<object type="video/x-msvideo" data="$i.localPath"  width="500" height="400">
													<param name="src" value="$i.localPath" />
													<param name="autostart" value="false" />
													<param name="controller" value="true" />
												</object> 
												<p>
													<strong>Download video:</strong> <a href="$i.localPath">Avi format | DivX format</a>
												</p>
											$elif i.VideoFormat == "MPEG" or i.VideoFormat == "OGG" or i.VideoFormat == "WEBM":
												<video controls="controls" width="500" height="400">
													<source src="$i.localPath" type="video/mp4" />
													<source src="$i.localPath" type="video/webm" />
													<source src="$i.localPath" type="video/ogg" />
												</video>
												<p>
													<strong>Download video:</strong> <a href="$i.localPath">MP4 format | Ogg format | WebM format</a>
												</p>
											$else:
												<video src="$i.localPath" controls="controls" width="500" height="400">
												</video>
												<p>
													<strong>Download video:</strong> <a href="$i.localPath">RM format | ASF format | MOV format</a>
												</p>
									</div>
								</div>
							</div>
							<div class="span1"></div>
								<div class="span4">
									<div class="coursera-course2-data">
										<h3 class="coursera-course-heading">Your review of this resource</h3>
										<div class="controls">
											<textarea name="" id="$(k)_$(i.id)-text-comments" style="width: 350px; height: 150px" class="large"></textarea>
										</div>
										<div class="shop-rating">
											<span class="title">Click to rate: </span>
											<ul class="rating-level" id="$(k)_$(i.id)">
												<li><a class="one-star" star:value="1" href="#" title="Terrible">1</a></li>
												<li><a class="two-stars" star:value="2" href="#" title="Poor">2</a></li>
												<li><a class="three-stars" star:value="3" href="#" title="Average">3</a></li>
												<li><a class="four-stars" star:value="4" href="#" title="Very Good">4</a></li>
												<li><a class="five-stars" star:value="5" href="#" title="Excellent">5</a></li>
											</ul>
											<span class="result" id="$(k)_$(i.id)-tips"></span> 
											<input type="hidden" id="$(k)_$(i.id)-input" name="" value="3" size="2" />
										</div>
										<input type="button" value="submit" class="btn btn-primary knowledge-rating-level" know_id="$(k)_$(i.id)"/>
									</div>
								</div>
							</div>
				<hr class="coursera-full-page-divider-no_padding">
				<div class="row-fluid">
					<div class="span12">
						<div style="margin-bottom: 3px;">
							<span style="font-weight: bold"
								data-msg="coursera-course-categories">Categories: </span>
							<a href="/contents?type=$knowinfo.knowledge"
								class="internal-home">$knowinfo.knowledge</a><br>
						</div>
						<div style="margin-bottom: 3px;">
							<a href="/history?type=$knowinfo.knowledge&name=$knowinfo.name"
								class="internal-home">View history of $knowinfo.knowledge:$knowinfo.name?</a><br>
						</div>
						<div style="margin-bottom: 3px;">
							<a href="/reuse?type=$knowinfo.knowledge&kid=$kinfo.id"
								class="internal-home">Make a revision ?</a><br>
						</div>
						<div style="margin-bottom: 3px;">
							<a href="/reuse?type=$knowinfo.knowledge&kid=$kinfo.id"
								class="internal-home">Copy as a module ?</a><br>
						</div>
					</div>
				</div>
				<div class="row-fluid">
					<div class="span12">
						<div style="border-top: 1px solid #CCC; padding-top: 30px; margin: auto; text-align: center; margin-top: 36px;">
							<a href="/contents"
								style="margin-top: 20px;; display: inline-block;"
								class="btn btn-large btn-primary internal-home">Browse more Knowledge</a>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
window.onload = knowledge_rating;
</script>